<?php


/**
* Puree CMS
* http://www.molotsoft.ru
*
* @package Puree_CMS
* @subpackage Admin/Behaviors
* @author Ivan Chistyakov <ivan@molotsoft.ru>
* @version $Id: field_schema.php 1183 2010-03-26 13:21:41Z molotsoft@gmail.com $
* @link $HeadURL: http://puree-cms.googlecode.com/svn/trunk/plugins/admin/models/behaviors/field_schema.php $
*/


class FieldSchemaBehavior extends ModelBehavior {

/******************************************************************************/

var $settings = array();

/******************************************************************************/

var $fieldInputSchema = array(
	// attachment
	'model' => array('type' => 'hidden'),
	'foreign_key' => array('type' => 'hidden'),
	// general
	'id' => array('type' => 'hidden'),
	'parent_id' => array('empty' => '(root)'),
	'lft' => array('type' => 'skip'),
	'rght' => array('type' => 'skip'),
	//'slug' => array(),
	//'name' => array(),
	//'label' => array(),
	//'caption' => array(),
	'brief' => array('type' => 'wysiwyg'),
	'content' => array('type' => 'wysiwyg'),
	'message' => array('type' => 'wysiwyg'),
	'quote' => array('type' => 'wysiwyg'),
	'biography' => array('type' => 'wysiwyg'),
	//'date_ontop' => array(),
	//'date_start' => array(),
	//'date_end' => array(),
	//'obtained' => array(),
	//'published' => array(),
	//'contacts' => array('type' => 'wysiwyg'),
	//'address' => array('type' => 'wysiwyg'),
	//'phones' => array('type' => 'wysiwyg'),
	//'displayed' => array(),
	'position' => array('type' => 'skip'),
	//'locked' => array(),
	//'hidden' => array(),
	//'disabled' => array(),
	'deleted' => array('type' => 'skip'),
	// image
	'image' => array('type' => 'image', 'tab' => 'image', 'params' => 'resize=max&x=1000&y=750'),
	'thumbnail' => array('type' => 'image', 'tab' => 'image', 'params' => 'source=image&resize=crop&x=160&y=160'),
	'logo' => array('type' => 'image', 'tab' => 'image'),
	'avatar' => array('type' => 'image', 'tab' => 'image', 'params' => 'resize=crop&x=80&y=80'),
	// picture
	'picture' => array('type' => 'image', 'tab' => 'picture', 'params' => 'resize=max&x=1000&y=750'),
	// photo
	'photo' => array('type' => 'image', 'tab' => 'photo', 'params' => 'resize=crop&x=200&y=300'),
	// file
	'file' => array('type' => 'file', 'tab' => 'file'),
	'pricelist' => array('type' => 'file', 'tab' => 'file'),
	// audio
	'audio' => array('type' => 'audio', 'tab' => 'audio'),
	'mp3' => array('type' => 'audio', 'tab' => 'audio'),
	// video
	'video' => array('type' => 'video', 'tab' => 'video'),
	'flv' => array('type' => 'video', 'tab' => 'video'),
	// meta
	//'meta_title' => array('tab' => 'meta'),
	//'meta_subtitle' => array('tab' => 'meta'),
	//'meta_description' => array('tab' => 'meta'),
	//'meta_keywords' => array('tab' => 'meta'),
	//'meta_copyright' => array('tab' => 'meta'),
	//'meta_header_text' => array('tab' => 'meta'),
	//'meta_footer_text' => array('tab' => 'meta'),
	// seo
	//'seo_title' => array('tab' => 'seo'),
	//'seo_subtitle' => array('tab' => 'seo'),
	//'seo_description' => array('tab' => 'seo'),
	//'seo_keywords' => array('tab' => 'seo'),
	//'seo_copyright' => array('tab' => 'seo'),
	//'seo_header_text' => array('tab' => 'seo'),
	//'seo_footer_text' => array('tab' => 'seo'),
	// info
	'note' => array('tab' => 'info'),
	'created' => array('type' => 'static', 'tab' => 'info'),
	'modified' => array('type' => 'static', 'tab' => 'info'),
	// user
	'username' => array('class' => 'username'),
	'password' => array('type' => 'password', 'class' => 'password'),
	//'first_name' => array(),
	//'last_name' => array(),
	'email' => array('class' => 'email'),
	'url' => array('class' => 'url')
);

/******************************************************************************/

function setup(&$Model, $settings = array()) {
	$this->settings[$Model->name] = (array)$settings;
}

/******************************************************************************/

function _describeFieldInput(&$Model, $field_name, $field_description = array(), $fill_options = FALSE, $id = NULL) {
	return $field_description['input'];
}

function describeFieldInput(&$Model, $field_name, $field_description = array(), $fill_options = FALSE, $id = NULL) {
	$field_description_default = array(
		'type' => 'string',
		'name' => $field_name,
		'input' => array(
			'label' => __($field_name . '_field', TRUE),
			'type' => 'text',
			'tab' => 'general',
			'params' => array()
		)
	);
	$field_description = array_merge($field_description_default, $field_description);
// ???
	return $field_description['input'];
}

/******************************************************************************/

}


?>